<?php

/* 
 * EachGo电商网站 新媒体
 * www.eachgo.cn
 */
namespace Home\Model;
use Think\Model;
class UserLotteryNumberInfoModel extends Model{
    //private String $sm;
    //获取所有信息
    public function queryAll(){ //查询所有信息      
        $result = $this->select();
        return $result;
    }
    public function addLotterNumber($data){//增加一条记录
        $result=$this->add($data);
        return $result;
    }
    /*
     * Function:updateLotterNumber
     * Param:
     * $id:记录的主键值
     * $level：改变那个字段，其中0表示luckyMoney，1表示oneLottery......
     * $newNumber:新的数量
     */
    public function updateLotterNumber($id,$level,$newNumber){
        if($level==0){
            $sql="UPDATE ".$this->tablePrefix."user_lottery_number_info SET luckyMoney=".$newNumber." WHERE ID=".$id;
        }else if($level==1){
            $sql="UPDATE ".$this->tablePrefix."user_lottery_number_info SET oneLottery=".$newNumber." WHERE ID=".$id;
        }else if($level==2){
            $sql="UPDATE ".$this->tablePrefix."user_lottery_number_info SET twoLottery=".$newNumber." WHERE ID=".$id;
        }else if($level==5){
            $sql="UPDATE ".$this->tablePrefix."user_lottery_number_info SET fiveLottery=".$newNumber." WHERE ID=".$id;
        }else if($level==1){
            $sql="UPDATE ".$this->tablePrefix."user_lottery_number_info SET tenLottery=".$newNumber." WHERE ID=".$id;
        }
       echo $sql;
       $result = $this->execute($sql);
       return $result;
    }
}
